<!Document>
<html>
<head>
    <title>同层渲染测试html</title>
    <meta name="viewport">
</head>
<body>
<div>
    <div id="bodyId">
        <object id="cameraTest" type = "application/view" width="800" height = "800" src = "test" style = "background-color:red">
            <param name="type" value="video">
            <param name="id" value="playerId">
            <param name="data" value="{'123'}">
            <param name="uc_render_mode" value="3">
            <param name="selfdraw" value="1">
        </object>
    </div>
</div>

<script>
let nativeEmbed = {
    //判断设备是否支持touch事件
    touch:('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch,
    nativeEmbed : document.getElementById('objectTest'),//或者“objectTest”

    //事件
    events:{
        nativeEmbed:document.getElementById('objectTest'),     //this为slider对象
        handleEvent:function(event){
            console.log("object event")
            var self = this;     //this指events对象
            if(event.type === 'touchstart'){
                self.start(event);
            }else if(event.type === 'touchmove'){
                self.move(event);
            }else if(event.type === 'touchend'){
                self.end(event);
            }
        },
        //滑动开始
        start:function(event){
            console.log("object start slide");
            this.nativeEmbed.removeEventListener('touchmove',this,false);
            this.nativeEmbed.removeEventListener('touchend',this,false);
        },
        move:function(event){
            console.log("object start move");
            //当屏幕有多个touch或者页面被缩放过，就不执行move操作

        },
        //滑动释放
        end:function(event){
            //解绑事件
            console.log("object end slide");
            this.nativeEmbed.removeEventListener('touchmove',this,false);
            this.nativeEmbed.removeEventListener('touchend',this,false);
        }

    },

    //初始化
    init:function(){
        let self = this;     //this指slider对象
        console.log("init:function");
        self.nativeEmbed.addEventListener('touchstart', self.events, false);    // addEventListener第二个参数可以传一个对象，会调用该对象的handleEvent属性
    }
};

nativeEmbed.init();
</script>
</body>
</html>
